/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jprojetocloseup;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

/**
 *
 * @author Rodrigo Toma
 */
public class LerCaminho {

    String retcaminhoPlaninha = "C:\\";
    String retcaminhoEnvioCloseUp = "C:\\";
    String retcaminhoMedico = "C:\\";
    String retCaminhoRetornoCloseUp = "C:\\"; 

    public void RetornoCaminho() {

        FileReader arquivoCaminho = null;
        File cam = null;
        String pasta;
        try {
            cam = new File(new File(".").getCanonicalPath());
            arquivoCaminho = new FileReader(cam + "\\CaminhoCloseUp.TXT");
            BufferedReader buffer = new BufferedReader(arquivoCaminho);
            String linha = buffer.readLine();

            for (int i = 0; i < 4; i++) {

                if (i == 0) {
                    retcaminhoPlaninha = linha;

                }
                if (i == 1) {
                    retcaminhoMedico = linha;

                }
                if (i == 2) {
                    retcaminhoEnvioCloseUp = linha;

                }
                if (i == 3) {
                    retCaminhoRetornoCloseUp = linha;

                }
                
                linha = buffer.readLine();
            }

            buffer.close();

        } catch (FileNotFoundException ex) {
            JOptionPane.showMessageDialog(null, "Falta do arquivo Caminho.txt");
        } catch (IOException ex) {
            Logger.getLogger(PrincipalCloseUp.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
            try {
                arquivoCaminho.close();
            } catch (IOException ex) {
                Logger.getLogger(PrincipalCloseUp.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

    }
    
    public void GravaCaminho(String planilha,String envio,String retorno,String retornoCloseUp) throws FileNotFoundException, IOException{
        
        File fw = null;
        FileOutputStream fos = null;
        fw = new File(new File(".").getCanonicalPath()+"\\CaminhoCloseUp.TXT");
        fos = new FileOutputStream(fw, false);
        
        fos.write((planilha + System.getProperty("line.separator")).getBytes());
        fos.write((envio + System.getProperty("line.separator")).getBytes());
        fos.write((retorno + System.getProperty("line.separator")).getBytes());
        fos.write((retornoCloseUp + System.getProperty("line.separator")).getBytes());
        
        fos.close();
        
    }
    
    
    
}
